#%RAML 0.8
title: Inventory API
version: v1.6
protocols: [ HTTP, HTTPS ]
baseUri: http://localhost

documentation:
  - title: "Inventory API"
    content: <b>API for interacting with an inventory of physical resources</b>

schemas:
 - item: !include schema/item.json
 - items: !include schema/items.json
 - instance: !include schema/instance.json
 - instances: !include schema/instances.json
 - context: !include schema/instance_context.json
 - ingest-status: !include schema/ingest_status.json

traits:
 - secured: !include ../shared/traits/auth.raml
 - language: !include ../shared/traits/language.raml
 - pageable: !include ../shared/traits/pageable.raml
 - searchable: !include ../shared/traits/searchable.raml

resourceTypes:
 - collection: !include ../shared/rtypes/collection.raml
 - collection-item: !include ../shared/rtypes/item-collection.raml

/inventory:
  /items:
    displayName: Items
    type:
      collection:
        exampleCollection: !include examples/items_get.json
        schemaCollection: items
        schemaItem: item
        exampleItem: !include examples/item_get.json
    get:
      is: [pageable,
          searchable: {description: "by title (using CQL)",
                       example: "title=\"*uproot*\""}]
    post:
    delete:
      responses:
        204:
          description: "All items deleted"
    /{itemId}:
      type:
        collection-item:
          exampleItem: !include examples/item_get.json
          schema: item
      get:
  /instances:
    displayName: Instances
    type:
      collection:
        exampleCollection: !include  examples/instances_get.json
        schemaCollection: instances
        schemaItem: instance
        exampleItem: !include examples/instance_get.json
    get:
      is: [pageable]
    post:
    delete:
      responses:
        204:
          description: "All instances deleted"
    /{instanceId}:
      type:
        collection-item:
          exampleItem: !include examples/instance_get.json
          schema: instance
      get:
    /context:
      get:
        description: "Provides Dublin Core context for instances"
        responses:
          200:
            description: "Dublin Core context for instances"
            body:
              application/json:
                example: !include examples/instance_context_get.json
                schema: context
  /ingest:
    /mods:
      post:
        body:
          multipart/form-data:
            formParameters:
              file:
                description: MODS file containing items to ingest
                required: true
                type: file
        responses:
          202:
            headers:
              location:
                description: URI pointing to the location of ingest status
          400:
            body:
              text/plain:
                example: "Cannot parse multiple files in a single request"
          500:
            body:
              text/plain:
      /status:
        /{id}:
          get:
            description: Status of a MODS ingest
            responses:
              200:
                body:
                  application/json:
                    example: !include examples/ingest_status_get.json
                    schema: ingest-status
              500:
                body:
                  text/plain:
